<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <div style="padding-top: 1rem;"></div>
      <!-- table -->
      <FilterTable
        ref="tableDetail"
        :columns="columns1"
        :params="fetchParams"
        :dataSource="dataList"
        :datakey="'items'"
        :onColumnsChange="columns => (this.columns = columns)"
        :onRowSelectChange="selectChange"
        selectionType="single"
        :is-select-column="false"
        :isPagination="false"
        height="auto"
      >
      </FilterTable>

      <div :style="{
        position: 'absolute',
        left: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }">
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
    </Spin>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { isFormEmpty } from '@/utils/index';

export default {
  mixins: [dictionary],
  components: {

  },
  props: ['rowData'],
  data() {
    return {
      loading: false,
      visible: false,
      visibleDrawer: false,
      collapse: false,
      rowDate: {},
      infoId: null,
      flterValue: {}, //参数
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      saveData: null,
      dataList: [],
      columns1: this.createTableColumns(),
      newVar: {}
    };
  },
  async created() {
    debugger;
    this.loading = true;
    await this.chuqi();
    console.log(this.rowData);
    await this.setFaultPartTableValue(this.rowData);
    this.loading = false;
  },

  methods: {

    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    async setFaultPartTableValue(records) {
      debugger;
      if (isFormEmpty(records)) {
        records = [];
      }
      this.$refs.tableDetail.$refs.pageTable.EXECUTE_INSERT(records);
    },
    async chuqi() {

    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //取消操作
    closeDialog() {
      this.$emit('close');
    },
    chooseOrderNo() {
      this.visible = true;
    },
    close() {
      this.visible = false;
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '备件代码', dataIndex: 'partCode', sorter: true },
        { title: '备件名称', dataIndex: 'partName', sorter: true },
        { title: '1-5000', dataIndex: 'faultNum1', sorter: true },
        { title: '5001-30000', dataIndex: 'faultNum2', sorter: true },
        { title: '30001-60000', dataIndex: 'faultNum3', sorter: true },
        { title: '60001-80000', dataIndex: 'faultNum4', sorter: true },
        { title: '80001-100000', dataIndex: 'faultNum5', sorter: true },
        { title: '100001-120000', dataIndex: 'faultNum6', sorter: true },
        { title: '120001-140000', dataIndex: 'faultNum7', sorter: true },
        { title: '140001-160000', dataIndex: 'faultNum8', sorter: true },
        { title: '160001-180000', dataIndex: 'faultNum9', sorter: true },
        { title: '180001-200000', dataIndex: 'faultNum10', sorter: true },
        { title: '200000以上', dataIndex: 'faultNum11', sorter: true },

      ]
    }

  }
};
</script>

<style lang="less" scoped>

</style>
